var o = require("../../../@babel/runtime/helpers/typeof"), t = getApp();

Page({
    data: {
        goodsId: "",
        city: "",
        longitude: "",
        latitude: "",
        shipAreaType: "",
        storeList: [],
        markers_2: [ {
            latitude: 23.099994,
            longitude: 113.32452,
            iconPath: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",
            width: 20,
            height: 25,
            callout: {
                padding: "10rpx",
                borderRadius: "5rpx"
            }
        } ],
        circle: [ {
            latitude: "",
            longitude: "",
            radius: "",
            fillColor: "#FF88887F",
            color: "#FFF",
            strokeWidth: 2,
            zIndex: 1
        } ],
        polygons_2: []
    },
    onLoad: function(t) {
        t.goodsId && this.setData({
            goodsId: t.goodsId,
            city: t.city
        }), console.log(o(this.data.longitude)), this.getRule();
    },
    getRule: function() {
        var o = this, i = {
            city: this.data.city,
            goods_id: this.data.goodsId
        }, e = t.getNetAddresss("plugin.yz-supply-cake.frontend.index.index.getRule");
        t._getNetWork({
            url: e,
            data: i,
            success: function(t) {
                var i = t.data;
                if (1 == i.result) {
                    var e, a, n, l;
                    if (console.log(i.data), 200 !== i.data.code) return wx.showToast({
                        icon: "none",
                        title: i.data.msg,
                        duration: 1500
                    }), void o.setData({
                        description: i.data.msg
                    });
                    var d = i.data, s = null === (e = d.data) || void 0 === e ? void 0 : e.ship_area_type, r = (null === (a = d.data) || void 0 === a ? void 0 : a.shop) || [];
                    if ("1" === s || 1 === s) {
                        var u, c, p, g, v, h = (JSON.parse(null === (u = d.data) || void 0 === u ? void 0 : u.ship_areas) || {}).areas || [];
                        console.log(h);
                        var f = [], y = [];
                        h.map(function(o, t) {
                            var i = o.points;
                            for (var e in y.push({
                                points: []
                            }), i) y[t].points.push({
                                latitude: i[e].lat,
                                longitude: i[e].lng
                            });
                            f.push({
                                points: y[t].points,
                                fillColor: "#FF88887F",
                                strokeColor: "#FFF",
                                strokeWidth: 2,
                                zIndex: 1
                            });
                        }), o.setData({
                            polygons_2: f,
                            latitude: null === (c = f[0]) || void 0 === c || null === (p = c.points[0]) || void 0 === p ? void 0 : p.latitude,
                            longitude: null === (g = f[0]) || void 0 === g || null === (v = g.points[0]) || void 0 === v ? void 0 : v.longitude
                        });
                    }
                    if ("2" === s || 2 === s) {
                        var m, _, F, k = JSON.parse(null === (m = d.data) || void 0 === m ? void 0 : m.ship_rule) || {};
                        console.log(k);
                        var w = k.non_default || {}, x = "";
                        for (var I in w) console.log(I), x = w[I].distance;
                        o.setData({
                            "circle[0].longitude": null === (_ = r[0]) || void 0 === _ ? void 0 : _.lng,
                            "circle[0].latitude": null === (F = r[0]) || void 0 === F ? void 0 : F.lat,
                            "circle[0].radius": 1e3 * x
                        });
                    }
                    o.setData({
                        storeList: r,
                        "markers_2[0].longitude": null === (n = r[0]) || void 0 === n ? void 0 : n.lng,
                        "markers_2[0].latitude": null === (l = r[0]) || void 0 === l ? void 0 : l.lat,
                        shipAreaType: s
                    }), console.log(o.data.shipAreaType);
                } else wx.showToast({
                    icon: "none",
                    title: i.msg,
                    duration: 1500
                });
            },
            fail: function(o) {
                console.log(o);
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});